package com.hakim.wfb.customer.service.task;

import org.springframework.stereotype.Component;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

/**
 * Created by Administrator on 2017/7/23.
 */
@Component
public class StaticProfitScheduleStarter24 {

    private final static long ONE_DAY_SECOND = 24 * 60 * 60 * 1000;

    public StaticProfitScheduleStarter24() {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.HOUR_OF_DAY, 2);
//        c.set(Calendar.HOUR_OF_DAY, 22);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        Date date = c.getTime();
        if (new Date().after(date)) {
            c.add(Calendar.DATE, 1);
            date = c.getTime();
        }
        Timer timer = new Timer();
        timer.schedule(new StaticProfitTask24(), date, ONE_DAY_SECOND);
    }
}
